'use strict';
const fs = require('fs');
const rimraf = require('rimraf');
const path = require('./path');

// 删除缓存
module.exports = () => {
    return new Promise(resolve => {
         // 判断文件是否存在
         fs.exists(`${path.rootPath}${path.cachePath}`, exists => {
            if(exists) {
                rimraf(`${path.rootPath}${path.cachePath}`, err => {
                    if (err) throw err;
                    resolve();
                });
            } else {
                resolve();
            }
        });
    });
};